# ifndef __UndoRedo_H_
# define __UndoRedo_H_

# include "Selection.h"

//
// The base class for all map changes.
//
class CEditAction {
  public:
	virtual ~CEditAction () {}

	// Append action description to _str.
	virtual void GetName (string_t & _str) const = 0;

	enum cu_t {cuYes, cuNo, cuBackup};
	virtual cu_t CanUndo () const = 0;
	// Return true if success.
	virtual bool Do () = 0;

	virtual void Undo () = 0;
	virtual void Redo () = 0;

	// Depth of nesting of combined actions. Return -1 to mark the action 'invisible' for grouping.
	// NOTE: ordinary actions should not override this.
	virtual int GetDepthLevel () const {return 0;}
};

//
// The undo/redo stack.
//
typedef std::list<CEditAction *> actions_t;
extern actions_t g_Undo;
extern actions_t g_Redo;

extern bool g_bModified;

bool PerformEditAction (CEditAction * _pAction);
void UndoEditAction ();
void RedoEditAction ();
void ResetUndoRedo ();

bool CanUndo ();
bool CanRedo ();
bool CanSave ();

# endif // __UndoRedo_H_